/* indent size: 1 */

module.exports = app => {
	const DataTypes = app.Sequelize;

	const Model = app.model.define('m_user', {
		id: {
			type: DataTypes.INTEGER(8).UNSIGNED,
			allowNull: false,
			primaryKey: true,
			autoIncrement: true
		},
		password: {
			type: DataTypes.STRING(32),
			allowNull: true,
			defaultValue: null
		},
		gender: {
			type: DataTypes.INTEGER(1).UNSIGNED,
			allowNull: true,
			defaultValue: '0'
		},
		birthday: {
			type: DataTypes.INTEGER(11).UNSIGNED,
			allowNull: true,
			defaultValue: '0'
		},
		register_time: {
			type: DataTypes.INTEGER(11).UNSIGNED,
			allowNull: true,
			defaultValue: '0'
		},
		last_login_time: {
			type: DataTypes.INTEGER(11).UNSIGNED,
			allowNull: true,
			defaultValue: '0'
		},
		last_login_ip: {
			type: DataTypes.STRING(15),
			allowNull: true,
			defaultValue: null
		},
		user_level_id: {
			type: DataTypes.INTEGER(3).UNSIGNED,
			allowNull: true,
			defaultValue: '0'
		},
		nickname: {
			type: DataTypes.STRING(60),
			allowNull: true
		},
		mobile: {
			type: DataTypes.STRING(20),
			allowNull: true
		},
		register_ip: {
			type: DataTypes.STRING(45),
			allowNull: true,
			defaultValue: null
		},
		avatar: {
			type: DataTypes.STRING(255),
			allowNull: true,
			defaultValue: null
		},
        user_id: {
            type: DataTypes.STRING(50),
            allowNull: false,
            defaultValue: '0',
            comment: '用户ID'
        },
		weixin_sessionkey: {
			type: DataTypes.STRING(50),
			allowNull: true,
			defaultValue: null
		},
		weixin_unionid: {
			type: DataTypes.STRING(50),
			allowNull: true,
			defaultValue: null
		},
        shop_id: {
            type: DataTypes.INTEGER(11),
            allowNull: true,
            defaultValue: null,
            comment: '商家ID，预留SASS功能'
		},
		is_delete: {
			type: DataTypes.INTEGER(1).UNSIGNED,
			allowNull: false,
			defaultValue: '0',
			comment: '是否删除，0->存在，1->删除'
		},
	}, {
		tableName: 'm_user',
		timestamps: false
	});

	Model.sync({ alter: true });
	
	return Model;
};
